define(['main', 'metisMenu'], function(){

    // MetsiMenu
    $('#side-menu li:not(.nav-header)').removeClass('active');
    var nav = $('#side-menu .nav-sys');
    nav.addClass('active');
    nav.find('li').eq(4).addClass('active');
    $('#side-menu').metisMenu();

    $('.ibox-content').on('keydown', '.tag_search', function(event) {
        
        if(event.keyCode == 13){
            event.preventDefault();
            var tagName = $(this).val();
            window.location.href = '/admin/sys2014/tag_info_query/'+tagName;
        }
        
    }); 
    $("#add_attr_but").click(function(argument) {
        var name=$("#attr_name").val();
         $.post("/admin/sys2014/add_attr",{"name":name},function(data){

            if(data.ret == 0){
                alert("添加成功");
             window.location.href = "";
            }else{
                alert("添加出错");
            }
          
        },"json");
    })
    /* Init DataTables 
    var oTable = $('#editable').dataTable({paging:true, pageLength:20,lengthMenu:[20,50]});*/

    /* Apply the jEditable handlers to the table */
    /*oTable.$('td:not(.notEdit)').editable( '/t', {
        "callback": function( sValue, y ) {
            sValue = JSON.parse(sValue);
            var aPos = oTable.fnGetPosition( this );
            if(aPos[1] == 0){
                sValue = sValue.data.name;
            }else if(aPos[1] == 1){
                sValue = sValue.data.num;
            }
            oTable.fnUpdate( sValue, aPos[0], aPos[1] );
        },
        "submitdata": function ( value, settings ) {

            return {
                "row_id": this.parentNode.getAttribute('id'),
                "column": oTable.fnGetPosition( this )[2]
            };
        },

        "width": "90%",
        "height": "100%"
    });

    $('.ibox-content').on('click', '#addRowBtn', function(event) {
        event.preventDefault();
        $('#editable').dataTable().fnAddData([
            "1",
            "New row",
            "New row",
        ]);
        oTable.$('td:not(.notEdit)').editable( '/t', {
            "callback": function( sValue, y ) {
                console.log(1,sValue, y);
                var aPos = oTable.fnGetPosition( this );
                oTable.fnUpdate( sValue, aPos[0], aPos[1] );
            },
            "submitdata": function ( value, settings ) {
                console.log(2,value, settings);
                return {
                    "row_id": this.parentNode.getAttribute('id'),
                    "column": oTable.fnGetPosition( this )[2]
                };
            },
    
            "width": "90%",
            "height": "100%"
        });
    });*/
    

});